package com.exercises;

import com.exercises.common.TreeNode;

import java.util.HashSet;
import java.util.LinkedList;
import java.util.Queue;
import java.util.Set;

/**
 * 9x9 的数独是否有效
 */
public class Exercise671 {
    private int min;
    private int current = -1;

    public int findSecondMinimumValue(TreeNode root) {
        min = root.val;
        dfs(root);
        return current;
    }

    public void dfs(TreeNode node) {
        if (node == null) return;
        int value = node.val;
        if (current != -1 && value > current) return;
        if (value > min) current = value;
        dfs(node.left);
        dfs(node.right);
    }
}
